﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="BabyJournal.ItemDetailPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:BabyJournal"
    xmlns:data="using:BabyJournal.Data"
    xmlns:common="using:BabyJournal.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.BottomAppBar>
        <AppBar x:Name="BottamApp" Padding="10,0,10,0" MinHeight="90" Background="#FF2488bf" BorderBrush="#FF2488bf">
            <Grid x:Name="grid" Margin="0,10" Height="124">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="21*"/>
                        <ColumnDefinition Width="21*"/>
                        <ColumnDefinition Width="21*"/>
                        <ColumnDefinition Width="21*"/>
                        <ColumnDefinition Width="16*"/>
                    </Grid.ColumnDefinitions>
                    <Button x:Name="BottAppbar1" HorizontalAlignment="Right" VerticalAlignment="Stretch" Style="{StaticResource NewApp}" Margin="0">
                        <Image HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Source="Assets/BottApp1.png"/>
                    </Button>
                    <Button x:Name="BottAppbar2" HorizontalAlignment="Right" VerticalAlignment="Stretch" Style="{StaticResource NewApp}" Margin="0" Grid.Column="1">
                        <Image HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Source="Assets/BottApp2.png"/>
                    </Button>
                    <Button x:Name="BottAppbar3" HorizontalAlignment="Right" VerticalAlignment="Stretch" Style="{StaticResource NewApp}" Margin="0" Grid.Column="2">
                        <Image HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Source="Assets/BottApp3.png"/>
                    </Button>
                    <Button x:Name="BottAppbar4" HorizontalAlignment="Right" VerticalAlignment="Center" Style="{StaticResource NewApp}" Margin="0" Grid.Column="3">
                        <Image HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Source="Assets/BottApp4.png"/>
                    </Button>
                </Grid>
            </Grid>
        </AppBar>
    </Page.BottomAppBar>


    <Page.Resources>

        <!-- Collection of items displayed by this page -->
        <CollectionViewSource
            x:Name="itemsViewSource"
            Source="{Binding Items}"
            d:Source="{Binding AllGroups[0].Items, Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}"/>
        <Style x:Key="topStyle" TargetType="TextBlock" BasedOn="{StaticResource HeaderTextStyle}">
        	<Setter Property="TextWrapping" Value="NoWrap"/>
        	<Setter Property="VerticalAlignment" Value="Bottom"/>
        	<Setter Property="Margin" Value="0,0,30,40"/>
        	<Setter Property="Text" Value="25 Jan 2012 "/>
        	<Setter Property="Foreground" Value="#FFFF406F"/>
        	<Setter Property="FontWeight" Value="Bold"/>
        </Style>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid x:Name="grid1"
        Style="{StaticResource LayoutRootStyle}"
        DataContext="{Binding Group}"
        d:DataContext="{Binding AllGroups[0], Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}">
    	<Grid.Background>
    		<ImageBrush ImageSource="Assets/bg.jpg"/>
    	</Grid.Background>

        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--
            The remainder of the page is one large FlipView that displays details for
            one item at a time, allowing the user to flip through all items in the chosen
            group
        -->
        <FlipView
            x:Name="flipView"
            AutomationProperties.AutomationId="ItemsFlipView"
            AutomationProperties.Name="Item Details"
            TabIndex="1"
            Grid.RowSpan="2"
            ItemsSource="{Binding Source={StaticResource itemsViewSource}}" Style="{StaticResource FlipViewNew}">

            <FlipView.ItemContainerStyle>
                <Style TargetType="FlipViewItem">
                    <Setter Property="Margin" Value="0,137,0,0"/>
                </Style>
            </FlipView.ItemContainerStyle>

            <FlipView.ItemTemplate>
                <DataTemplate>

                    <!--
                        UserControl chosen as the templated item because it supports visual state management
                        Loaded/unloaded events explicitly subscribe to view state updates from the page
                    -->
                    <UserControl Loaded="StartLayoutUpdates" Unloaded="StopLayoutUpdates">
                        <ScrollViewer x:Name="scrollViewer" Style="{StaticResource HorizontalScrollViewerStyle}" Grid.Row="1">

                            <!-- Content is allowed to flow across as many columns as needed -->
                            <Grid Height="578" Width="Auto" Margin="120,0,0,0" VerticalAlignment="Top">
                            	<Grid.Background>
                            		<ImageBrush/>
                            	</Grid.Background>
                            	<Grid.ColumnDefinitions>
                            		<ColumnDefinition Width="525"/>
                            		<ColumnDefinition Width="889*"/>
                            	</Grid.ColumnDefinitions>
                        		<RichTextBlock x:Name="richTextBlock" IsTextSelectionEnabled="False" Style="{StaticResource ItemRichTextStyle}" Margin="0" VerticalAlignment="Top">
                            		
                            		<Paragraph LineStackingStrategy="MaxHeight">
                            			<InlineUIContainer>
<Grid x:Name="MainGrid" Width="506" Height="496">
    		<Grid.Background>
    			<ImageBrush/>
    		</Grid.Background>
    		<Image Source="ms-appx:///Assets/GalleryPage/GalleryBig.png"/>
    		<Image HorizontalAlignment="Center" Height="342" VerticalAlignment="Center" Width="444" Margin="0,-34,0,0" Source="Assets/GalleryPage/Gallerpic.png" Stretch="Fill"/>
    	</Grid>                            			</InlineUIContainer>
                            		</Paragraph>
                            	
                            	</RichTextBlock>
                        		<Grid HorizontalAlignment="Left" Height="470" VerticalAlignment="Top" Width="629" Grid.Column="3" Margin="0,28,50,0">
                        			<Grid.Background>
                        				<ImageBrush ImageSource="Assets/DetailPage/DetailBg.png"/>
                        			</Grid.Background>
                        			<StackPanel Margin="15,20,10,20">
                        				<TextBlock TextWrapping="Wrap" Text="It was a funny day for Juppy" FontFamily="Segoe UI" FontSize="24" Foreground="#FF0D465B" FontWeight="ExtraBold" Margin="0,0,0,30"/>
                        				<TextBlock TextWrapping="Wrap" Text="&quot;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed &quot;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed &quot;Lorem ipsum dolor sit amet, consectetur adipisicing elit, &quot;Lorem ipsum dolor sr adipisicing elit, sed &quot;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed &quot;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed &quot;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed &quot;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed &quot;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed " FontFamily="Segoe UI" FontSize="20" Foreground="#FF0D465B" LineStackingStrategy="BlockLineHeight" LineHeight="32"/>
                        			</StackPanel>
                        		</Grid>
                        		<common:RichTextColumns x:Name="richTextColumns" Grid.ColumnSpan="2" Grid.Column="1" HorizontalAlignment="Stretch" Visibility="Collapsed">
                        			<common:RichTextColumns.ColumnTemplate>
                        				<DataTemplate>
                        					<RichTextBlockOverflow Margin="80,0,0,0" Width="560">
                        						<RichTextBlockOverflow.RenderTransform>
                        							<TranslateTransform X="-1" Y="4"/>
                        						</RichTextBlockOverflow.RenderTransform>
                        					</RichTextBlockOverflow>
                        				</DataTemplate>
                        			</common:RichTextColumns.ColumnTemplate>
                        		</common:RichTextColumns>

                        	</Grid>

                            <VisualStateManager.VisualStateGroups>

                                <!-- Visual states reflect the application's view state inside the FlipView -->
                                <VisualStateGroup x:Name="ApplicationViewStates">
                                    <VisualState x:Name="FullScreenLandscape"/>
                                    <VisualState x:Name="Filled"/>

                                    <!-- Respect the narrower 100-pixel margin convention for portrait -->
                                    <VisualState x:Name="FullScreenPortrait">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="richTextColumns" Storyboard.TargetProperty="Margin">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="97,0,87,57"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>

                                    <!-- When snapped, the content is reformatted and scrolls vertically -->
                                    <VisualState x:Name="Snapped">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="richTextColumns" Storyboard.TargetProperty="Margin">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="17,0,17,57"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="scrollViewer" Storyboard.TargetProperty="Style">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource VerticalScrollViewerStyle}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="richTextBlock" Storyboard.TargetProperty="Width">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="280"/>
                                            </ObjectAnimationUsingKeyFrames>

                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                        </ScrollViewer>
                    </UserControl>
                </DataTemplate>
            </FlipView.ItemTemplate>
        </FlipView>

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="pageTitle" Grid.Column="1" IsHitTestVisible="false" Style="{StaticResource topStyle}" Margin="8,0,30,40"/>
        </Grid>
        <Grid x:Name="Snaped" HorizontalAlignment="Left" Height="100" Opacity="0" VerticalAlignment="Top" Width="100" Visibility="Collapsed">
        	<TextBlock x:Name="textBlock_Copy" HorizontalAlignment="Center" TextWrapping="Wrap" Text="Please switch to full screen to view the details." VerticalAlignment="Center" FontFamily="Segoe UI" FontSize="24" Foreground="White" Margin="19.63,352.231,18.37,351.769" Opacity="0" Visibility="Collapsed"/>
        </Grid>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The back button respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="pageTitle">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Thickness>32,0,30,40</Thickness>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background)" Storyboard.TargetName="grid1">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                                    <SolidColorBrush Color="#FFC4E2E4"/>
                                </DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!-- The back button and title have different styles when snapped -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="flipView">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Visibility>Collapsed</Visibility>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    	<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Snaped" d:IsOptimized="True"/>
                    	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.RowSpan)" Storyboard.TargetName="Snaped">
                    		<DiscreteObjectKeyFrame KeyTime="0">
                    			<DiscreteObjectKeyFrame.Value>
                    				<x:Int32>2</x:Int32>
                    			</DiscreteObjectKeyFrame.Value>
                    		</DiscreteObjectKeyFrame>
                    	</ObjectAnimationUsingKeyFrames>
                    	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="Snaped">
                    		<DiscreteObjectKeyFrame KeyTime="0">
                    			<DiscreteObjectKeyFrame.Value>
                    				<x:Double>NaN</x:Double>
                    			</DiscreteObjectKeyFrame.Value>
                    		</DiscreteObjectKeyFrame>
                    	</ObjectAnimationUsingKeyFrames>
                    	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="Snaped">
                    		<DiscreteObjectKeyFrame KeyTime="0">
                    			<DiscreteObjectKeyFrame.Value>
                    				<x:Double>NaN</x:Double>
                    			</DiscreteObjectKeyFrame.Value>
                    		</DiscreteObjectKeyFrame>
                    	</ObjectAnimationUsingKeyFrames>
                    	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.HorizontalAlignment)" Storyboard.TargetName="Snaped">
                    		<DiscreteObjectKeyFrame KeyTime="0">
                    			<DiscreteObjectKeyFrame.Value>
                    				<HorizontalAlignment>Stretch</HorizontalAlignment>
                    			</DiscreteObjectKeyFrame.Value>
                    		</DiscreteObjectKeyFrame>
                    	</ObjectAnimationUsingKeyFrames>
                    	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.VerticalAlignment)" Storyboard.TargetName="Snaped">
                    		<DiscreteObjectKeyFrame KeyTime="0">
                    			<DiscreteObjectKeyFrame.Value>
                    				<VerticalAlignment>Stretch</VerticalAlignment>
                    			</DiscreteObjectKeyFrame.Value>
                    		</DiscreteObjectKeyFrame>
                    	</ObjectAnimationUsingKeyFrames>
                    	<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="textBlock_Copy" d:IsOptimized="True"/>
                    	<ColorAnimation Duration="0" To="Black" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="textBlock_Copy" d:IsOptimized="True"/>
                    	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="textBlock_Copy">
                    		<DiscreteObjectKeyFrame KeyTime="0">
                    			<DiscreteObjectKeyFrame.Value>
                    				<Visibility>Visible</Visibility>
                    			</DiscreteObjectKeyFrame.Value>
                    		</DiscreteObjectKeyFrame>
                    	</ObjectAnimationUsingKeyFrames>
                    	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="BottamApp">
                    		<DiscreteObjectKeyFrame KeyTime="0">
                    			<DiscreteObjectKeyFrame.Value>
                    				<Visibility>Collapsed</Visibility>
                    			</DiscreteObjectKeyFrame.Value>
                    		</DiscreteObjectKeyFrame>
                    	</ObjectAnimationUsingKeyFrames>
                    	<DoubleAnimation Duration="0" To="26.667" Storyboard.TargetProperty="(TextBlock.FontSize)" Storyboard.TargetName="pageTitle" d:IsOptimized="True"/>
                    	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="Snaped">
                    		<DiscreteObjectKeyFrame KeyTime="0">
                    			<DiscreteObjectKeyFrame.Value>
                    				<Visibility>Visible</Visibility>
                    			</DiscreteObjectKeyFrame.Value>
                    		</DiscreteObjectKeyFrame>
                    	</ObjectAnimationUsingKeyFrames>
                    	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background)" Storyboard.TargetName="grid1">
                    		<DiscreteObjectKeyFrame KeyTime="0">
                    			<DiscreteObjectKeyFrame.Value>
                    				<SolidColorBrush Color="#FFC4E2E4"/>
                    			</DiscreteObjectKeyFrame.Value>
                    		</DiscreteObjectKeyFrame>
                    	</ObjectAnimationUsingKeyFrames>
                    	
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
